//
//  SAFNetworking.h
//  TSBanPai
//
//  Created by wandong on 2017/10/16.
//  Copyright © 2017年 tingshan. All rights reserved.
//

#import <AFNetworking/AFNetworking.h>
typedef void(^successBlock)(NSDictionary * responseObject);
typedef void(^failureBlock)(NSURLResponse * response, NSError *error);
@interface SAFNetworking : AFHTTPSessionManager
+ (instancetype)shareInstance;

//post 请求
+ (void)POSTJSON:(NSString *)urlStr Paramter:(NSDictionary *)param  success:(successBlock)success failure: (failureBlock)failure;
//get 请求
+ (void)GETJSON:(NSString *)urlStr Paramter:(NSDictionary *)param  success:(successBlock)success failure: (failureBlock)failure;
//PUT请求
+ (void)PUTJSON:(NSString *)urlStr Paramter:(NSDictionary *)param  success:(successBlock)success failure: (failureBlock)failure;

//上传文件
+ (void)UPLOADDATA:(NSString *)urlStr Paramter:(NSDictionary *)param filename:(NSString*)filename file:(id)data success:(successBlock)success failure: (failureBlock)failure progress: (SActionBlock1)progress;
+ (NSString *)getCurrentMonth;

////下载文件+缓存 异步
//+ (NSURLSessionDownloadTask * )DOWNLOAD:(NSString*)urlStr Parameter:(NSDictionary *)param addition:(NSString*)addition filetype:(NSString*)filetype success:(SActionBlock1)success failure: (failureBlock)failure progress: (SActionBlock1)progress;
////下载文件+缓存 同步
//+ (NSURLSessionDownloadTask * )DOWNLOAD_SYNC:(NSString*)urlStr Parameter:(NSDictionary *)param addition:(NSString*)addition filetype:(NSString*)filetype success:(SActionBlock1)success failure: (failureBlock)failure progress: (SActionBlock1)progress;

@end

//缓存
/*
 *Library/Caches：保存应用运行时生成的需要持久化的数据，iTunes同步设备时不会备份该目录。一般存储体积大、不需要备份的非重要数据
 数存储在tmp目录
 */
//@interface SCache : NSObject
////数据库路径
//+(NSString*)FMDBPath;
////创建文件名
//+(NSString*)createFileName:(NSString*)type;
////创建文件路径 type 可为nil
//+(NSString*)createFilePath:(NSString*)type;
////根据文件名获取文件路径
//+(NSString*)filePath:(NSString*)fileName;
////初始化数据库和表 每次app打开时初始化一下
//+(BOOL)initFMDBAndKeyValueTable;
////保存文件 可以是data 可以是NSURL 可以是文件路径
//+(NSString*)save:(NSString *)key addition:(id)addition data:(id)data type:(NSString*)type;
////保存文件路径
//+(void)saveFilePath:(NSString*)key addition:(id)addition filePath:(NSString*)filePath;
////获取文件路径
//+(NSString*)getFilePath:(NSString *)key addition:(id)addition;
////获取数据
//+(NSData*)getData:(NSString *)key addition:(id)addition;
////删除键值对和文件，只有在键值对删除的情况下才删文件，防止键值对没删，文件被删除了
//+(BOOL)deleteFile:(NSString *)key addition:(id)addition;
//+(BOOL)clearAll;
//@end
